package com.job.meituan;

import java.util.*;
public class Meituan0820 {

    public static void e(String[] args) {
        Scanner sc =new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[m];
        long sumA = 0;
        long sumB = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            b[i] = sc.nextInt();
        }
        int[][] dp = new int[n][m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                dp[i][j] = Math.abs(a[i]-b[j]);
            }
        }

        long sum = 0;
        int i=0,j=0;
        while(i<n || j<m){
            int ad = Math.abs(a[i]);
            int bd = Math.abs(a[i]);
            if(dp[i][j] < ad && dp[i][j]<bd){
                sum+=dp[i][j];
                i++;j++;
            }else if(ad<bd){
                sum+=ad;
                i++;
            }else{
                sum+=bd;
                j++;
            }
        }
        if(i<n){
            for (int k = i; k < n; k++) {
                sum+=a[i];
            }
        }
        if(j<m){
            for (int k = i; k < m; k++) {
                sum+=b[i];
            }
        }

        System.out.println(sum);
    }

    public static void d(String[] args) {
        Scanner sc =new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] b = new int[n];
        int[] a = new int[m];
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int res =0;
        for (int i = 0; i < n; i++) {
            if(b[i] > a[m-1]){
                System.out.println(-1);
                return ;
            }
            int idx = find(a, 0,m-1, b[i]);
            res+=a[idx];
        }
        System.out.println(res);
    }

    public static int find(int[] a, int left, int right, int target){
        while(left < right){
            int mid = (left + right) >>1;
            if(a[mid] >=target) right =mid;
            else left =mid;
        }
        return left;
    }

    //AC
    public static void c(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        long[] pi =  new long[n];
        for (int i = 0; i < n; i++) {
            pi[i] = sc.nextInt();
        }

        long[] ai = new long[n];
        for (int i = 0; i < n; i++) {
            ai[i] = sc.nextInt();
        }

        long[] up = new long[n];
        long sum =0;
        for (int i = 0; i < n; i++) {
            up[i] = (100-pi[i]) * ai[i];
            sum += pi[i]*ai[i];
        }

        Arrays.sort(up);

        for (int i = up.length-1; m>0; i--,m--) {
            sum += up[i];
        }
        System.out.println(String.format("%.2f", sum/100D));

    }

    //AC
    public static void b(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        int x3 = sc.nextInt();
        int y3 = sc.nextInt();
        int d1 = sc.nextInt();
        int d2 = sc.nextInt();
        int d3 = sc.nextInt();

        int x1min = Math.max(1, x1-d1), x1max = Math.min(n, x1+d1), y1min = Math.max(1, y1-d1), y1max = Math.min(n, y1+d1);
        int x2min = Math.max(1, x2-d2), x2max = Math.min(n, x2+d2), y2min = Math.max(1, y2-d2), y2max = Math.min(n, y2+d2);
        int x3min = Math.max(1, x1-d1), x3max = Math.min(n, x3+d3), y3min = Math.max(1, y3-d3), y3max = Math.min(n, y3+d3);

        int xstart = Math.max(Math.max(x1min,x2min), x3min), xend = Math.min(Math.min(x1max, x2max),x3max);
        int ystart = Math.max(Math.max(y1min,y2min), y3min), yend = Math.min(Math.min(y1max, y2max),y3max);
        for (int i = xstart; i <= xend; i++) {
            for (int j = ystart; j <= yend; j++) {
                if(Math.abs(i-x1)+Math.abs(j-y1)==d1 && Math.abs(i-x2)+Math.abs(j-y2)==d2 && Math.abs(i-x3)+Math.abs(j-y3)==d3){
                    System.out.println(i+" "+j);
                    return ;
                }
            }
        }
    }

    //AC
    public static void a(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        sc.nextLine();
        char[] A = sc.nextLine().toCharArray();
        char[] B = sc.nextLine().toCharArray();

        for (int i = 0; i < n; i++) {
            System.out.print(A[i]);
            System.out.print(B[i]);
        }
        System.out.println();
    }
}
